#{extends 'Links/base.html' /}
#{set 'showLinkCategoryInfo'}
<li class='active'>
	<a href="#" >信息页</a>
</li>
#{/set}
		

	<div class=" nav-tabs box-div">
	    <h4>类别名称：</h4>
	    <hr>
		<form class="form-inline"  action="@{LinkCategories.editLinkCategory}">
            <input type='hidden' name='linkCategory.id' value='${linkCategory.id}'>
            <div class="form-group">
	    				<label for="linkCategory.name"></label>
	    				<input type="text" name="linkCategory.name" value='${linkCategory.name}' class="form-control" placeholder="输入新类别名称：" required="required">
	  		</div>
            <input type='hidden' name='linkCategory.status' value='${linkCategory.status}'>
            <input type='hidden' name='linkCategory.sequence' value='${linkCategory.sequence}'> 
            <div class="form-group">
		   				<button class='btn btn-success' type='submit' >保存</button>
		   				<a class='btn btn-primary' type='submit' href='@{LinkCategories.showLinkCategories}' >返回</a>
		   </div>
		</form>
	    <hr>
		<h4>新增链接</h4>
		<table class="table">
			<thead>
			    <th>序号</th>
				<th>名称</th>
				<th>地址</th>
				<th>类别</th>
				<th>操作</th>
			</thead>
			<tbody>
			#{list items:linkList,as:'link'}
				<tr>
				    <td>${link_index}</td>
					<td>${link.name}</td>
					<td><a href='${link.url}' target='_blank'>${link.url}</a></td>
					<td>${link.getLinkCategory()?.name}</td>
					<td><a href="@{Links.delLink(link.id,linkCategory.id)}" onclick="return confirm('删除链接：${link.name}?')" style="color:#08c;">删除</a></td>
				</tr>
			#{/list}

                <form class="form-inline"  action="@{Links.saveLink}">
					<tr>
						<td>${(link_index==null?'':link_index)+1}</td>
					<td>
						<div class="form-group">
	    				<label class="sr-only" for="link.name">名称：</label>
	    				<input type="text" maxlength="30" name="link.name" class="form-control" placeholder="输入链接名称：" required="required">
	  				    </div>
  				    </td>
  				    <td>
						<div class="form-group">
	    				<label class="sr-only" for="link.url">地址：</label>
	    				<input type="text" name="link.url" onblur="checkUrl(this)" class="form-control" placeholder="输入链接地址：">
	  				    </div>
  				    </td>
 					<td><button type="submit" class="btn btn-success" href="#">添加</button></td>
 					<td><input type="hidden" name="link.categoryId" value='${linkCategory.id}'></td>
					</tr>
				</form>

			</tbody>
		</table>
	
	</div>



#{set 'moreScripts'}
<script type="text/javascript">
function checkUrl(obj){
   var pattern=/http(s)?:////([/w-]+/.)+[/w-]+(//[/w- .//?%&=]*)?/;
   var str = obj.value;
   if(str.match(pattern)==null) obj.value="http://"+obj.value;
}

</script>
#{/set}

